package com.ruoyi.web.controller.test;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.web.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Program: RuoYi-Vue-chy->TaskController
 * @Description: 处理多线程的
 * @Author: hongyu.chen
 * @Date: 2025-03-06 16:03
 * @Version： 1.0
 **/
@RestController
@RequestMapping("/api/tasks")
public class TaskController extends BaseController {

    @Autowired
    private TaskService taskService;

    @PostMapping("/process")
    public String processTask(@RequestParam("details") String details) {
        taskService.processTask(details);
        return "Task received: " + details;
    }

    @GetMapping("/result")
    public String getTaskResult(@RequestParam("details") String details) {
        return taskService.getTaskResult(details);
    }

    @PostMapping("/processTaskAsync")
    public String processTaskAsync(@RequestParam("details") String taskId) {
        taskService.processTaskAsync(taskId);
        return "Task received: " + taskId;
    }

}
